<?php

namespace App\Http\Controllers\applet_api;

use App\Http\Controllers\Controller;
use App\Models\AppActivity;
use Illuminate\Http\Request;

class ActivityController extends Controller
{

    public function index(Request $Request)
    {
        $type = $Request->type ?: 0;
        $sql = AppActivity::select('id','title','banner')->where('status',1)->when($type, function ($query, $type) {
            return $query->where('type',$type);
        });
        $data = $sql->orderBy('sort','asc')->get();
        return response()->json(['code' => '200', 'msg' => 'success','data'=>$data]);
    }

    public function info(Request $Request)
    {
        $data = AppActivity::find($Request->id);
        return response()->json(['code' => '200', 'msg' => 'success','data'=>$data]);
    }
}
